#ifndef _DICOM_HANDLER_FILE_UPLOAD_HANDLER__
#define _DICOM_HANDLER_FILE_UPLOAD_HANDLER__

#include "dicom/web_server.h"
#include "dicom/storage/local_cache.h"
#include "dicom/session.h"
#include "gwbase/encrypt/digest.h"

namespace dicom {

class FileUploadHandler : public HttpHandler {
 public:
  FileUploadHandler(onion_request* conn) : HttpHandler(conn) {}

  virtual ~FileUploadHandler() {}
  virtual int HandleRequest(onion_request* conn, onion_response* resp);

  virtual const char* GetName() const { return "FileUploadHandler"; }
  static void RegisterHandler(WebServer* s);

 private:
  // File is stored plainly in /tmp/ by onion
  Status SavePlainFileToCache(const std::string fid,
                              const std::string& filename, HashEntry* hash);

  // File has already been encryptend on-the-fly when onoin store PUT data
  Status SaveEncryptFileToCache(const std::string fid,
                                const std::string& filename, HashEntry* hash);
};
}

#endif  // _DICOM_HANDLER_FILE_UPLOAD_HANDLER__
